package servlet;

import dao.OrderDAO;
import dao.OrderItemDAO;
import dao.ProductDAO;
import entity.OrderItem;
import entity.Product;
import org.bson.types.ObjectId;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "OrderInfo",value = "/order/info")
public class OrderInfoServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
        String id=req.getParameter("id");
        ObjectId oid=new ObjectId(id);
        OrderItemDAO orderItemDAO=new OrderItemDAO();

        List<OrderItem> pro = orderItemDAO.findByParentId(oid);
        req.setAttribute("pro",pro);
        req.getRequestDispatcher("/order/ItemList.jsp").forward(req,resp);
    }

}
